



//定时器运行周期
`define TIME_ARR            16'd2500



//FOC运行模式
`define FOC_MODE_STOP       6'b0000_01
`define FOC_MODE_OPEN       6'b0000_10 
`define FOC_MODE_TORQUE     6'b0001_00
`define FOC_MODE_SPEED      6'b0010_00 
`define FOC_MODE_POSTION    6'b0100_00 
`define FOC_MODE_SELFTEST   6'b1000_00 

//FOC 速度/位置环控制周期
`define FOC_SPEED_POSTION_CYC 3'd5


//UQ UD 参数的最大最小值
`define UQ_MAX      ($signed(32'd1100) <<< 16)
`define UQ_MIN      ($signed(-32'd1100) <<< 16)
`define UD_MAX      ($signed(32'd1100) <<< 16)
`define UD_MIN      ($signed(-32'd1100) <<< 16)

//电流的最大最小值
`define I_MAX       ($signed(32'd900) <<< 16)
`define I_MIN       ($signed(-32'd900) <<< 16)

//电流PID 积分最大最小值
`define I_PID_INTEGRAL_MAX  ($signed(32'd3500) <<< 16)
`define I_PID_INTEGRAL_MIN  ($signed(-32'd3500) <<< 16)


//速度PID 积分最大最小值
`define SPEED_PID_INTEGRAL_MAX  ($signed(32'd3500) <<< 16)
`define SPEED_PID_INTEGRAL_MIN  ($signed(-32'd3500) <<< 16)

`define PID_SPEED_MAX   ($signed(32'd800) <<< 16)
`define PID_SPEED_MIN   ($signed(-32'd800) <<< 16)


//位置PID 积分最大最小值
`define POSITION_PID_INTEGRAL_MAX  ($signed(32'd3500) <<< 16)
`define POSITION_PID_INTEGRAL_MIN  ($signed(-32'd3500) <<< 16)

`define PID_POSITION_MAX   ($signed(32'd1000) <<< 16)
`define PID_POSITION_MIN   ($signed(-32'd1000) <<< 16)


//位置环最大最小圈数
`define POSITION_MAX `ENCODER_ABZ_ONE_CIRCLE * 100
`define POSITION_MIN `ENCODER_ABZ_ONE_CIRCLE * 100


//编码器分辨率


`define ENCODER_ABZ_PLUS_NUM        $signed(16'd2048)
`define ENCODER_ABZ_MIN_RESOLUTION  $signed('d11520)
`define ENCODER_ABS_MIN_RESOLUTION  $signed('d1440)
`define ENCODER_ONE_CIRCLE          $signed('d23592960)